from tkinter import *
from lxg_tkinter import demos, Quitter


class Demo(Frame):
    def __init__(self, parent=None, **options):
        Frame.__init__(self, parent, **options)
        self.pack()
        Label(self, text='按钮栏').pack()
        # 遍历并创建按钮
        for (k, _) in demos.items():
            # 定义函数，获取到各种输入框的返回值
            func = (lambda k=k: self.printit(k))
            Button(self, text=k, command=func).pack(side=TOP, fill=BOTH)
        Quitter(self).pack(side=TOP, fill=BOTH)

    def printit(self, name):
        print(name, '返回值是：', demos[name]())


if __name__ == '__main__':
    Demo().mainloop()
